package small.common.statistic.base;

import small.common.statistic.data.MetricBucket;
import small.common.statistic.data.WindowWrap;

/**
 * 适用于稳定的流量场景
 *
 * @author jinzhou
 * @data 2023/4/7 11:13
 */
public class BucketLeapArray extends LeapArray<MetricBucket> {

    public BucketLeapArray(int sampleCount, int intervalInMs) {
        super(sampleCount, intervalInMs);
    }

    @Override
    public MetricBucket newEmptyBucket(long timeMillis) {
        return new MetricBucket();
    }

    @Override
    protected WindowWrap<MetricBucket> resetWindowTo(WindowWrap<MetricBucket> w, long startTime) {
        //重置窗口开始时间和计数器
        w.resetTo(startTime);
        w.value().reset();
        return w;
    }
}
